import { defineStore } from 'pinia';
import { ref } from 'vue'

export interface LoginInfo {
  isLogin: boolean
  isAdmin: boolean
}

export const useLoginStore = defineStore('login', () => {
  const loginInfo = ref<LoginInfo>({
    isLogin: false,
    isAdmin: false
  })

  function setLoginInfo(info: LoginInfo) {
    loginInfo.value = info
  }

  function clearLoginInfo() {
    loginInfo.value = {
      isLogin: false,
      isAdmin: false
    }
  }
  return { loginInfo, setLoginInfo, clearLoginInfo }
}, { persist: true })